﻿using BO.News;
using GUI.Extensions;

namespace GUI.Controls.News
{
    public partial class EmbedGroup3 : System.Web.UI.UserControl
    {

        private const int ImageWidth = 320;
        private const int ImageHeight = 240;
        private const int TopHighlight = 1;
        private const int TopOther = 2;




        internal void DataBind(int zoneId1, int zoneId2)
        {
            var bo = CacheSettingExtensions.EnableCacheHtml
                         ? NewsBO_NoCache.GetInstance()
                         : NewsBO.GetInstance();
            //var listNews = new List<NewsObject>();
            //CategoryObject zone1 = null, zone2 = null;


            if (zoneId1 > 0)
            {
                var zone1 = NewsBO.GetInstance().GetCategoryDetail(zoneId1);

                if (zone1 != null)
                {
                    var list1 =
                        bo.ImportNewsWhileNotEnough(zoneId1, TopHighlight, TopOther);

                    if (list1 != null && list1.Count > 0)
                    {
                        ctrNewsZone1.DataBind(zone1, list1, ImageWidth, ImageHeight);
                    }
                }
            }

            if (zoneId2 > 0)
            {
                var zone = NewsBO.GetInstance().GetCategoryDetail(zoneId2);

                if (zone != null)
                {
                    var list = bo.ImportNewsWhileNotEnough(zoneId2, TopHighlight, TopOther);
                    if (list != null && list.Count > 0)
                    {
                        ctrNewsZone2.DataBind(zone, list, ImageWidth, ImageHeight);
                    }
                }
            }

        }
    }
}